home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 326-350 / disk_326 / popscreen / pops.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  111 lines

  1. /********************************************************
  2.   pops.c  PopScreen   main routine (start and end)
  3.  
  4.   Written by Stephen Vermeulen 403-282-7990
  5.           PO Box 3295, Station B,
  6.           Calgary, Alberta,
  7.           CANADA, T2M 4L8
  8.  
  9.   This is public domain for what it is worth...
  10.  
  11.   This is a little routine I wrote when I got annoyed by
  12.   VLT's lack of screen to front and back gadgets.  It allows
  13.   you to pop the selected screen to the front from the CLI.
  14.  
  15.   Typing POPS by itself will give you a list of screens
  16.   and their current numbers, and then typing something
  17.   like:
  18.  
  19.          POPS 2
  20.  
  21.   will pop screen number 2 to the front.  If you run something
  22.   like DMouse, Qmouse... you probably will not need this.
  23. *********************************************************/
  24.  
  25. #include <intuition/intuitionbase.h>
  26. #include <intuition/intuition.h>
  27. #include <stdio.h>
  28. #include <functions.h>
  29.  
  30. /** global variables go here...
  31.  **/
  32.  
  33. struct IntuitionBase *IntuitionBase;
  34. struct GfxBase *GfxBase;
  35.  
  36.  
  37. open_libs()
  38. {
  39.   IntuitionBase = (struct IntuitionBase *)
  40.                   OpenLibrary("intuition.library", 0L);
  41.   GfxBase =       (struct GfxBase *)
  42.                   OpenLibrary("graphics.library", 0L);
  43.   if (!IntuitionBase || !GfxBase) return(FALSE);
  44.  
  45.   /**** Successful opening of libraries ****/
  46.  
  47.   return(TRUE);
  48. }
  49.  
  50. close_libs()
  51. {
  52.   if (IntuitionBase) { CloseLibrary(IntuitionBase);  IntuitionBase = NULL; }
  53.   if (GfxBase)       { CloseLibrary(GfxBase);  GfxBase = NULL; }
  54. }
  55.  
  56. char names[4000];
  57. struct Screen *slist[20];
  58. short nlist[20];
  59.  
  60. main(argc, argv)
  61. int argc;
  62. char *argv[];
  63. {
  64.   struct Screen *s;
  65.   int i, pos;
  66.  
  67.   if (open_libs())
  68.   {
  69.     if (argc > 1)
  70.     {
  71.       i = atoi(argv[1]);
  72.       Forbid();
  73.       s = IntuitionBase->FirstScreen;
  74.       while (s && (i > 0))
  75.       {
  76.         --i;
  77.         s = s->NextScreen;
  78.       }
  79.       Permit();
  80.       if (s) ScreenToFront(s);
  81.     }
  82.     else
  83.     {
  84.       puts("PopScreen [screen number]");
  85.       puts("By Stephen Vermeulen, Box 3295, Stn. B, Calgary, Alta., CANADA, T2M 4L8");
  86.       puts("A little utility to pop the indicated screen to the front");
  87.       i = 0;
  88.       pos = 0;
  89.       Forbid();
  90.       s = IntuitionBase->FirstScreen;
  91.       while (s && (i < 20))
  92.       {
  93.         slist[i] = s;
  94.         strcpy(&names[pos], s->DefaultTitle);
  95.         nlist[i] = pos;
  96.         pos += strlen(&names[pos]) + 1;
  97.         if (pos > 3900) break;
  98.         ++i;
  99.         s = s->NextScreen;
  100.       }
  101.       Permit();
  102.       puts("Screen   Name");
  103.       for (pos = 0; pos < i; ++pos)
  104.         printf("%6d   %s\n", pos, &names[nlist[pos]]);
  105.     }
  106.     close_libs();
  107.   }
  108. }
  109.  
  110.  
  111.